<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2016/10/12
 * Time: 16:38
 * Project name: PHPTEST
 * File name: 2.php
 * @copyright Copyright (c) 2016 ZRX Software LLC
 * @license https://github.com/zhangrxiang
 */

// 返回路径中的文件名部分
echo basename(__FILE__,'.php');
echo "<br>";
echo basename('https://github.com/zhangrxiang','zhangrxiang');
echo "<br>";
echo basename('zhangrxiang.php','.php');
echo "<br>";
echo "1) ".basename("/etc/sudoers.d", ".d").PHP_EOL;
echo "<br>";
echo "2) ".basename("/etc/passwd").PHP_EOL;
echo "<br>";
echo "3) ".basename("/etc/").PHP_EOL;
echo "<br>";
echo "4) ".basename(".").PHP_EOL;
echo "<br>";
echo "<br>";
echo "<br>";
echo "5) ".basename("/");
echo "<br>";


// 返回路径中的目录部分
echo dirname('https://github.com/zhangrxiang');
echo "<br>";
echo dirname(__FILE__);

echo "<br>";
var_dump(pathinfo('https://github.com/zhangrxiang'));
var_dump(pathinfo(__FILE__));



echo "<br>";
//$ext = end(explode(".", (__FILE__)));
//var_dump(end(explode(".", (__FILE__))));





function getExtension($file){
    $pos = strrpos($file, '.');
    return substr($file, $pos + 1);
}
